home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / lzw4c13.zip / COMPRESS.C < prev    next >
Text File  |  1993-08-29  |  1KB  |  45 lines

  1. /*
  2. **  COMPRESS.C      Copyright (C) 1992 by MarshallSoft Computing, Inc.
  3. **
  4. **  Compresses specified file. Use EXPAND to un-compress file.
  5. **  Usage is:  COMPRESS <input_file> <output_file>
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "LZW4C.H"
  11. #include "RW_IO.H"
  12.  
  13. void main(argc,argv)
  14. int argc;
  15. char *argv[];
  16. {int RetCode;
  17.  float Ratio;
  18.  /* begin */
  19.  if(argc<3)
  20.     {printf("Usage: COMPRESS <infile> <outfile>\n");
  21.      exit(1);
  22.     }
  23.  if((RetCode=InitLZW(malloc,14))<0)
  24.     {SayError(RetCode);
  25.      exit(2);
  26.     }
  27.  /* open input file */
  28.  if(!ReaderOpen(argv[1])) exit(3);
  29.  /* open output file */
  30.  if(!WriterOpen(argv[2])) exit(4);
  31.  printf("Compressing %s ",argv[1]);
  32.  /* do the compression */
  33.  if((RetCode=Compress(Reader,Writer))<0)
  34.    {SayError(RetCode);
  35.     exit(3);
  36.    }
  37.  if(ReaderCount() > 0)
  38.    {Ratio = (float)(WriterCount())/(float)ReaderCount();
  39.     printf(" %0.2f\n",Ratio);
  40.    }
  41.  /* close files */
  42.  ReaderClose();
  43.  WriterClose();
  44.  TermLZW(free);
  45. }